<?php

  require_once 'JooS/Browser/Abstract.php';

  class JooS_Browser_Firefox extends JooS_Browser_Abstract {
    protected function getName() {
      return "Firefox";
    }
    
    protected function getVersion() {
      $ua = $this->getUA();

      $rv = null;
      $gecko = null;
      $ff = null;
      if ($gecko = preg_match_all("/\sGecko\/(\d{6})/", $ua, $match) ? $match[1][0] : false) {
        if ($ff = preg_match_all("/\sFirefox\/(\d+\.\d)/", $ua, $match) ? $match[1][0] : false) {
        }
        elseif ($rv = preg_match_all("/\srv:(\d+\.\d+(\.\d+)*)/", $ua, $match) ? $match[1][0] : false) {
          if (version_compare('1.7', $rv, '>'))
            $ff = "0.1";
          elseif (version_compare('1.8', $rv, '>'))
            $ff = "1.0";
          elseif (version_compare('1.8.1', $rv, '>'))
            $ff = "1.5";
          elseif (version_compare('1.9', $rv, '>'))
            $ff = "2.0";
          elseif (version_compare('1.9.1', $rv, '>'))
            $ff = "3.0";
          else
            $ff = "3.1";
        }
        else {
          if ($gecko < "200411")
            $ff = "0.1";
          elseif ($gecko < "200511")
            $ff = "1.0";
          elseif ($gecko < "200610")
            $ff = "1.5";
          elseif ($gecko < "200806")
            $ff = "2.0";
          else
            $ff = "3.0";
        }
      }
      if ($ff && version_compare('1.0', $ff, '>'))
        $this->throwException($ff);

      return $ff;
    }
  }

?>